/**
 *  Copyright 2009-2010 Steven Ottenhoff (Dual-IT)
 * 
 *  This file is part of Clazzified.
 *
 *  Clazzified is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Clazzified is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Clazzified.  If not, see http://www.gnu.org/licenses/gpl.
 * 
 */

package nl.dualit.clazzified.core.model;

import java.util.concurrent.atomic.AtomicBoolean;

import nl.dualit.clazzified.core.model.attribute.IAttribute;

/**
 * Represent a value of an object attribute.
 * 
 * @author steffo
 *
 */
public class ObjektData implements Cloneable {
	private String clazzName;
	private String attributeName;
	private Object data;
	
	private IAttribute attribute;
	private AtomicBoolean isLocked;
	private Object owner;
	
	public static ObjektData getInstance( IAttribute attribute, Object data ){
		return new ObjektData( attribute, data );
	}
	
	public static ObjektData getInstance( IAttribute attribute ){
		return new ObjektData( attribute );
	}
	
	private ObjektData( IAttribute attribute ){
		this.attribute = attribute;
	}
	
	private ObjektData( IAttribute attribute, Object data ){
		this.attribute = attribute;
		this.data = data;
	}
	
	public String getClazzName() {
		return clazzName;
	}
	
	public void setClazzName(String clazzName) {
		
		// TODO Must retrieve existing clazz.
		
		this.clazzName = clazzName;
	}
	
	public String getAttributeName() {
		return attributeName;
	}
	
	public void setAttributeName(String attributeName) {
	
		this.attributeName = attributeName;
	}
	
	public Object getData() {
		return data;
	}
	
	public void setData(Object data) {
		
		this.data = data;
	}

	public IAttribute getAttribute() {
		return attribute;
	}

	public void setAttribute(IAttribute attribute) {
		
		this.attribute = attribute;
	}

	/**
	 * Shows if internal data structure is set. Returns true when IAttribute
	 * is not null.
	 * 
	 * @return
	 */
	public boolean isInternal(){
		return ( attribute == null ) ? false : true;
	}
	
}
